﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace eLearning.Business
{
    public class LibraryItemQuizAnswerRepository
    {
        // Create an instance of entities framework
        eLearningEntities entities = new eLearningEntities();
        public List<LibraryItemQuizAnswer> GetAll(int quizId)
        {
            return (from c in entities.LibraryItemQuizAnswers where c.QuizId == quizId select c).ToList();
        }
        public List<LibraryItemQuizAnswer> GetAll()
        {
            return (from c in entities.LibraryItemQuizAnswers select c).ToList();
        }
        public LibraryItemQuizAnswer GetSingle(int id)
        {
            return (from c in entities.LibraryItemQuizAnswers where c.Id == id select c).FirstOrDefault();
        }
        public void Create(LibraryItemQuizAnswer _object)
        {
            entities.AddToLibraryItemQuizAnswers(_object);
            entities.SaveChanges();
        }
        public void Update(LibraryItemQuizAnswer _object)
        {
            entities.SaveChanges();
        }
        public void Delete(int id)
        {
            var _object = (from _list in entities.LibraryItemQuizAnswers where _list.Id == id select _list).First();
            entities.DeleteObject(_object);
            entities.SaveChanges();
        }
    }
}